#include<sys/types.h>
#include<sys/stat.h>
#include<unistd.h>
#include<string.h>
#include<fcntl.h>
#include<stdio.h>

#define LEN 100

int main(){
    int fd, len;
    char buf[LEN];

    fd = open("hello.txt", O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
    if(fd){
        write(fd, "hello, world", strlen("hello,world") + 1);
        close(fd);
    }
    fd = open("hello.txt",O_RDWR);
    len = read(fd, buf, LEN);
    buf[len] = '\0';
    printf("%s\n", buf);
    close(fd);
}